
import { _decorator, director } from 'cc';
import BasePanel from '../../../core/component/BasePanel';
import Data from '../../../core/manager/Data';
import WindowManager from '../../../core/manager/WindowManager';
import WXTTUtils from '../../../core/manager/WXTTUtils';
import AudioMgr from '../../../core/utils/AudioMgr';
import { Main } from '../Main';
const { ccclass, property } = _decorator;

@ccclass('PauseLayer')
export class PauseLayer extends BasePanel {

    onDestroy() {
        this.dispatch("PAUSE_LAYER_CLOSE")
        super.onDestroy();
    }
    start()
    {
        WXTTUtils.showInterstitialAd()
    }

    onBtnClicked(event: any, customEventData: any) {
        AudioMgr.Instance().playSFX('btnclick')
        var btnName = event.target.name;
        switch (btnName) {
            case "btn_close":
                this.close();
                break;
            case "btn_hall":
                Data.user.life--;
                Data.user.life_cost_time = Date.now();
                this.close();
                Main.Instance().backHall();
                break;
            case "btn_replay":
                this.close();
                WindowManager.ins.open("LevelLayer");
                break;
            case "btn_back":
                this.close();
                break;
        }
    }

}
